package org.iteam.xlz.manager.action.message;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.iteam.web.shiro.ShiroUtil;
import org.iteam.web.struts.action.AbstractModuleAction;
import org.iteam.web.struts.action.RestAction;
import org.iteam.xlz.core.entity.messages.FeedbackType;
import org.iteam.xlz.core.service.base.ColumnTypeService;
import org.iteam.xlz.core.service.message.FeedbackTypeService;


@SuppressWarnings("unchecked")
@Results({@Result(name="INDEX",type="freemarker",location="/WEB-INF/content/message/feedbackType/index.html"),
		  @Result(name="EDIT",type="freemarker",location="/WEB-INF/content/message/feedbackType/edit.html")})
public class FreedbackTypeAction extends AbstractModuleAction<FeedbackType> implements RestAction{

	/**
	 * 
	 */
	private static final long serialVersionUID = -6048707290244843311L;
	private final String PATH="/message/freedbackType";
	@Override
	public FeedbackType getModel() {
		if(null==model){
			model=new FeedbackType();
		}
		return model;
	}
	@Override
	@Action(PATH+"/index")
	public String index() throws Exception {
		return INDEX;
	}

	@Override
	@Action(PATH+"/query")
	public String query() {
		map.put("total",FeedbackTypeService.getInstance().counts());
		map.put("rows",FeedbackTypeService.getInstance().query(page,rows));
		return MAP;
	}

	@Override
	@Action(PATH+"/create")
	public String create() {
		model.setCreator(ShiroUtil.currentAccount());
		map.put("state",FeedbackTypeService.getInstance().create(model));
		return MAP;
	}

	@Override
	@Action(PATH+"/update")
	public String update() {
		map.put("state",FeedbackTypeService.getInstance().update(model));		
		return MAP;
	}

	@Override
	@Action(PATH+"/{_id}/delete")
	public String delete() {
		map.put("state",FeedbackTypeService.getInstance().delete(_id));
		return MAP;
	}

	@Override
	public String destroy() {
		return null;
	}


	@Override
	@Action(PATH+"/{_id}/edit")
	public String edit() throws Exception {
		super.object=FeedbackTypeService.getInstance().findOne(_id);
		return EDIT;
	}

	@Override
	@Action(PATH+"/new")
	public String editNew() throws Exception {
		return EDIT;
	}
	@Override
	public String show() {
		return null;
	}
	
	@Action(PATH+"/getTypeList")
	public String getTypeList(){
		array = FeedbackTypeService.getInstance().getTypeList();
		return ARRAY;
	}
}
